package main

import (
	"context"
	"net"

	"google.golang.org/grpc"

	"traning/grpc_test/proto"
)

type Server struct {
}

func (this *Server) Hello (ctx context.Context, request *proto.HelloRequest) (req *proto.Respons, err error) {
	return &proto.Respons{
		Reply: "hello " + request.Name,
	}, nil
}

func main(){
	g := grpc.NewServer()
	proto.RegisterHelloServer(g, &Server{})
	list, err := net.Listen("tcp", "0.0.0.0:8080")
	if err != nil {
		panic("启动服务失败")
	}
	err = g.Serve(list)
	if err != nil {
		panic("grpc 启动失败")
	}


}